
package gui.view;
import gui.controller.EditKlassenController;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.EventHandler;

import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.WindowConstants;



public class EditKlassenItemSet extends JDialog {
	private JTextField suchTextFeld;
	private JTextField textField;
	private JList alleItemsList;
	private JList setItemList;
	
    public EditKlassenItemSet(Window owner, final EditKlassenController controller) {

        DefaultListModel defaultListModel = new DefaultListModel();

        DefaultListModel defaultListModel2 = new DefaultListModel();
      
        JPanel contentPane = (JPanel) getContentPane();
                                GridBagLayout gridBagLayout = new GridBagLayout();
                                gridBagLayout.columnWidths = new int[]{39, 187, 44, 27, 234, 0};
                                gridBagLayout.rowHeights = new int[]{14, 20, 20, 208, 23, 23, 0};
                                gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
                                gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
                                getContentPane().setLayout(gridBagLayout);
                                        
                                                JLabel label4 = new JLabel();
                                                label4.setText("Alle Gegenstände");
                                                GridBagConstraints gbc_label4 = new GridBagConstraints();
                                                gbc_label4.anchor = GridBagConstraints.NORTH;
                                                gbc_label4.insets = new Insets(0, 0, 5, 5);
                                                gbc_label4.gridx = 1;
                                                gbc_label4.gridy = 0;
                                                contentPane.add(label4, gbc_label4);
                                
                                        JLabel label3 = new JLabel();
                                        label3.setText("Gegenstandsset");
                                        GridBagConstraints gbc_label3 = new GridBagConstraints();
                                        gbc_label3.anchor = GridBagConstraints.NORTH;
                                        gbc_label3.insets = new Insets(0, 0, 5, 0);
                                        gbc_label3.gridx = 4;
                                        gbc_label3.gridy = 0;
                                        contentPane.add(label3, gbc_label3);
                                        
                                                suchTextFeld = new JTextField();
                                                suchTextFeld.setColumns(8);
                                                suchTextFeld.setName("suchTextFeld");
                                                suchTextFeld.addActionListener(EventHandler.create(ActionListener.class, controller, "suchen"));
                                                
                                                        JLabel label2 = new JLabel();
                                                        label2.setText("Suchen");
                                                        GridBagConstraints gbc_label2 = new GridBagConstraints();
                                                        gbc_label2.insets = new Insets(5, 5, 5, 5);
                                                        gbc_label2.gridx = 0;
                                                        gbc_label2.gridy = 2;
                                                        contentPane.add(label2, gbc_label2);
                                                
                                                GridBagConstraints gbc_suchTextFeld = new GridBagConstraints();
                                                gbc_suchTextFeld.anchor = GridBagConstraints.NORTH;
                                                gbc_suchTextFeld.fill = GridBagConstraints.HORIZONTAL;
                                                gbc_suchTextFeld.insets = new Insets(0, 0, 5, 5);
                                                gbc_suchTextFeld.gridx = 1;
                                                gbc_suchTextFeld.gridy = 2;
                                                contentPane.add(suchTextFeld, gbc_suchTextFeld);
                                
                                        JLabel lblSetname = new JLabel();
                                        lblSetname.setText("Set-Name");
                                        GridBagConstraints gbc_lblSetname = new GridBagConstraints();
                                        gbc_lblSetname.anchor = GridBagConstraints.EAST;
                                        gbc_lblSetname.insets = new Insets(0, 0, 5, 5);
                                        gbc_lblSetname.gridx = 3;
                                        gbc_lblSetname.gridy = 2;
                                        contentPane.add(lblSetname, gbc_lblSetname);
                                
                                        textField = new JTextField();
                                        textField.setColumns(14);
                                        
                                        GridBagConstraints gbc_textField = new GridBagConstraints();
                                        gbc_textField.anchor = GridBagConstraints.NORTH;
                                        gbc_textField.fill = GridBagConstraints.HORIZONTAL;
                                        gbc_textField.insets = new Insets(0, 0, 5, 5);
                                        gbc_textField.gridx = 4;
                                        gbc_textField.gridy = 2;
                                        contentPane.add(textField, gbc_textField);
                                alleItemsList = new JList();
                                alleItemsList.setDragEnabled(true);
                                alleItemsList.setModel(defaultListModel);
                                alleItemsList.setName("alleItemsList");
                                alleItemsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                                
                                
                                        JScrollPane scrollPane = new JScrollPane(alleItemsList);
                                        scrollPane.setPreferredSize(new Dimension(23, 23));
                                        scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
                                        GridBagConstraints gbc_scrollPane = new GridBagConstraints();
                                        gbc_scrollPane.fill = GridBagConstraints.BOTH;
                                        gbc_scrollPane.insets = new Insets(5, 5, 5, 5);
                                        gbc_scrollPane.gridwidth = 2;
                                        gbc_scrollPane.gridx = 0;
                                        gbc_scrollPane.gridy = 3;
                                        contentPane.add(scrollPane, gbc_scrollPane);
                                
                                        JButton button = new JButton();
                                        button.addActionListener(new ActionListener() {
                                        	@Override
											public void actionPerformed(ActionEvent arg0) {
                                        		controller.delGegenstand();
                                        	}
                                        });
                                        button.setText("Gegenstand entfernen");
                                        
                                        
                                        JScrollPane scrollPane_2 = new JScrollPane();
                                        GridBagConstraints gbc_scrollPane_2 = new GridBagConstraints();
                                        gbc_scrollPane_2.fill = GridBagConstraints.BOTH;
                                        gbc_scrollPane_2.insets = new Insets(0, 0, 5, 5);
                                        gbc_scrollPane_2.gridwidth = 2;
                                        gbc_scrollPane_2.gridx = 3;
                                        gbc_scrollPane_2.gridy = 3;
                                        getContentPane().add(scrollPane_2, gbc_scrollPane_2);
                                        
                                                setItemList = new JList();
                                                scrollPane_2.setViewportView(setItemList);
                                                setItemList.setModel(defaultListModel2);
                                                setItemList.setName("klassenitemList");
                                                setItemList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                                                
                                        GridBagConstraints gbc_button = new GridBagConstraints();
                                        gbc_button.insets = new Insets(0, 0, 5, 0);
                                        gbc_button.gridx = 4;
                                        gbc_button.gridy = 4;
                                        contentPane.add(button, gbc_button);
                                
                                        JButton button2 = new JButton();
                                        button2.setText("Speichern");
                                        button2.addActionListener(EventHandler.create(ActionListener.class, controller, "speichern"));
                                        
                                                JButton button3 = new JButton();
                                                button3.setText("Abbrechen");
                                                button3.addActionListener(EventHandler.create(ActionListener.class, controller, "close"));
                                                GridBagConstraints gbc_button3 = new GridBagConstraints();
                                                gbc_button3.anchor = GridBagConstraints.NORTH;
                                                gbc_button3.insets = new Insets(5, 5, 5, 5);
                                                gbc_button3.gridx = 1;
                                                gbc_button3.gridy = 5;
                                                contentPane.add(button3, gbc_button3);
                                        GridBagConstraints gbc_button2 = new GridBagConstraints();
                                        gbc_button2.insets = new Insets(5, 5, 5, 5);
                                        gbc_button2.anchor = GridBagConstraints.NORTH;
                                        gbc_button2.gridx = 4;
                                        gbc_button2.gridy = 5;
                                        contentPane.add(button2, gbc_button2);
        this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    }
	public JTextField getJSuchTextFeld() {
		return suchTextFeld;
	}
	public JTextField getJNameTextField() {
		return textField;
	}
	public JList getJAlleItemsList() {
		return alleItemsList;
	}
	public JList getJSetItemList() {
		return setItemList;
	}
}
